Skip to content

feat(pm-console): refresh open PRs from edge - #12548

Open
dezren39 wants to merge 5 commits into
mainfrom
queue/21047-12518-edge-ops
Open

dezren39 wants to merge 5 commits into
mainfrom
queue/21047-12518-edge-ops

Conversation

@dezren39

@dezren39 dezren39 commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Summary

Evidence

  • Before: open PRs remained at the last laptop report while the laptop was away.
  • After: bun test — 112 pass; npm run build — pass; git diff --check — pass.
  • Ran on the laptop worktree after merging current origin/main into the branch.

Merge Danger

  • Low: direct reads are disabled unless GITHUB_READ_ENABLED=on and GITHUB_TOKEN are configured; no write endpoint is added.

Refs #12518


Prove it works
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 22, 2026 13:18
@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 52 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 41abd382-bb53-4f16-a97a-44811ab1705b
Commits

Reviewing files that changed from the base of the PR and between 5133832 and 18d9220.

Files selected for processing: 6

  • pm-stack/console/edge/README.md
  • pm-stack/console/edge/src/edge.ts
  • pm-stack/console/edge/src/github.ts
  • pm-stack/console/edge/src/worker.ts
  • pm-stack/console/src/docs.ts
  • pm-stack/console/test/edge.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T00:06:47.171570Z 18d9220 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b989032429

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pm-stack/console/edge/src/github.ts Resolved
Comment thread pm-stack/console/edge/src/edge.ts Resolved
Comment thread pm-stack/console/edge/src/edge.ts Resolved
dezren39 added a commit that referenced this pull request Nov 22, 2026
…top is away

The edge runs the real Ops and Work classes in the Durable Object once
the laptop has been quiet for 60s, through a new edge run translator
(edge/src/direct.ts): fleet gh api argv become GitHub REST calls,
fleet secrets get becomes a Worker secret, and the queue store is
already reached by fetch. Laptop-only verbs answer needs the laptop.

Direct reads: board, prs, priorities, asks. Direct writes: ask.send,
ask.reply, ask.close, issue.comment, need.comment, issue.rank,
task.move. A new prompt files its issue at the edge and holds only
prompt.enqueue for the laptop, which runs ops.enqueue on return; a
reply posts its comment once at the edge and is never repeated. The
no-twice rule stands: an action relayed with no answer is only ever
resolved by the laptop.

EdgeConfig gains queueDbUrl, queueTokenName, promptLabel, needsRepos.
scripts/expose.py gains --edge-direct (off by default, remembered like
--edge) provisioning GITHUB_TOKEN, QUEUE_TOKEN and EDGE_DIRECT;
health reports the capability and an hourly self-check of one read of
each kind.

This supersedes the approach of PR #12548 for the PR read: its
dedicated readOpenPullRequests/freshRead is replaced by Ops.prs()
through the same run/fetch, so the PR read shares the one path.

Tests: bun test 130 pass (was 110) — 13 direct translator tests, 6
new edge integration tests, 1 enqueue-hook test. The edge bundles:
wrangler deploy --dry-run, 126.87 KiB.

Refs #12518
dezren39 added a commit that referenced this pull request Nov 22, 2026
…top is away (#12579)

* pm-console: run queue and GitHub operations at the edge while the laptop is away

The edge runs the real Ops and Work classes in the Durable Object once
the laptop has been quiet for 60s, through a new edge run translator
(edge/src/direct.ts): fleet gh api argv become GitHub REST calls,
fleet secrets get becomes a Worker secret, and the queue store is
already reached by fetch. Laptop-only verbs answer needs the laptop.

Direct reads: board, prs, priorities, asks. Direct writes: ask.send,
ask.reply, ask.close, issue.comment, need.comment, issue.rank,
task.move. A new prompt files its issue at the edge and holds only
prompt.enqueue for the laptop, which runs ops.enqueue on return; a
reply posts its comment once at the edge and is never repeated. The
no-twice rule stands: an action relayed with no answer is only ever
resolved by the laptop.

EdgeConfig gains queueDbUrl, queueTokenName, promptLabel, needsRepos.
scripts/expose.py gains --edge-direct (off by default, remembered like
--edge) provisioning GITHUB_TOKEN, QUEUE_TOKEN and EDGE_DIRECT;
health reports the capability and an hourly self-check of one read of
each kind.

This supersedes the approach of PR #12548 for the PR read: its
dedicated readOpenPullRequests/freshRead is replaced by Ops.prs()
through the same run/fetch, so the PR read shares the one path.

Tests: bun test 130 pass (was 110) — 13 direct translator tests, 6
new edge integration tests, 1 enqueue-hook test. The edge bundles:
wrangler deploy --dry-run, 126.87 KiB.

Refs #12518

* pm-console: answer Codex review on #12579

- direct.ts: send an explicit User-Agent with GitHub REST requests;
  Workers supplies none and GitHub requires it.
- edge-proto.ts: accept configs stored or reported before direct mode
  (new direct fields empty); gate direct capabilities on the config
  carrying them instead of refusing the whole config.
- edge.ts: hydrate the durable mirror before a first direct read, so a
  failed read after a restart keeps last-good data; keep notification
  refreshes from reloading the mirror over freshly read sections.
- actions.ts: a failed deferred prompt.enqueue throws, so the held
  action is reported failed instead of recorded done with no queue task.
- expose.py: remember the direct-mode choice only after the Worker has
  it, so a failed run retries instead of assuming the mode is set.

Tests: 134/134 console tests (bun test), 19/19 expose tests; each new
test fails against the pre-fix code.

---------

Co-authored-by: Drewry Pope <dezren39@users.noreply.github.com>
GitHub rejects requests without a valid User-Agent, and a Cloudflare
Worker sends none by default, so the direct PR read failed even with
a valid token. Addresses review thread on #12548 (github.ts:22).
The ops document awaited the GitHub read (up to the 20s timeout) on
every request while the laptop was silent, stalling the Next, ranked
issue, agent and service views too. The read now runs in the
background through the Durable Object's waitUntil, shared while one
is already running, and only for a stale section, so the document
answers at once from cache and the fresh list arrives on the next
poll.

Also in Docs.refresh: a load that finishes after a newer read must
not put its older copy back, so the background record cannot be
overwritten by the document's own stale-section mirror load.
Addresses review threads on #12548 (edge.ts:594).
A failed GitHub read stamped the section's time before the stored
copy was ever loaded, so after a Durable Object restart the PR view
stayed on 'Loading...' even with a good laptop snapshot in storage:
the stamped time both skipped the initial mirror load (which only
runs for sections never read) and kept the 90s staleness window from
ever elapsing, since the frontend polls every 20s. The failure path
now reads the persisted section back first, then records the failure,
so the last good list stays visible with the failure reported in its
health. Addresses review thread on #12548 (edge.ts:596).
@dezren39
dezren39 removed the request for review from a team November 23, 2026 05:56

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant